package com.tarena.starter.autoconfigure;

import com.tarena.starter.autoconfigure.bean.UserBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
//properties yml属性必须 user.bean.enabled=true 才满足条件
@ConditionalOnProperty(prefix = "user",value = "enabled",havingValue = "true")
public class UserBeanAutoConfiguration {
    @Bean(name="userbean")
    @ConditionalOnMissingBean(UserBean.class)
    public UserBean userbean(){
        return new UserBean();
    }
}
